package com.roc.web.action.freeze;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class FreezingMerchantSearchCondition extends BaseSearchCondition {
	
	private static final long serialVersionUID = 1L;
	private String mchntCd;//商户号
	private String useStatus;//冻结启用状态标志 0 不启用，1启用
	private String freezeFlag;//冻结满标志 0 未冻满，  1 冻满
	private String date;
	private String opr;
	private String remark;
	private String oldKeys;
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		if(Constance.isNotEmpty(mchntCd)){
			filedBeanList.add(new WhereHQLFieldBean("t.mchnt_cd", mchntCd,"=", false));
		}
		if(Constance.isNotEmpty(useStatus)){
			filedBeanList.add(new WhereHQLFieldBean("t.use_status", useStatus,"=", false));
		}
		if(Constance.isNotEmpty(freezeFlag)){
			filedBeanList.add(new WhereHQLFieldBean("t.freeze_flag", freezeFlag,"=", false));
		}
		if(Constance.isNotEmpty(date)){	
			filedBeanList.add(new WhereHQLFieldBean("to_char(t.rec_crt_ts,'yyyy-MM-dd')",date, "=", false));
		}
		if(Constance.isNotEmpty(opr)){	
			filedBeanList.add(new WhereHQLFieldBean("t.resver2", opr.trim(), "like", false,"ALL"));
		}
		if(Constance.isNotEmpty(remark)){	
			filedBeanList.add(new WhereHQLFieldBean("t.resver1", remark.trim(), "like", false,"ALL"));
		}
		if(Constance.isNotEmpty(oldKeys)){	
			filedBeanList.add(new WhereHQLFieldBean("t.old_trans_key", oldKeys.trim(), "like", false,"ALL"));
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" select count(1) from apstfr.tbl_tfr_mchnt_freeze_list t where 1=1");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" select t.key_str,t.mchnt_cd,t.freeze_amt,t.freeze_had_sum,t.freeze_wei_sum,t.use_status,t.freeze_flag,"
				+ "t.old_trans_key,t.old_trans_card_no,to_char(t.rec_crt_ts,'yyyy-MM-dd'),to_char(t.rec_upd_ts,'yyyy-MM-dd'),t.resver1,t.resver2,"
				+ "nvl(tb.name,'无效商户') names,(select s.real_name from t_operators s where to_char(s.id) = o.companyid) as branchcompy,"
				+ "(select s.real_name from t_operators s where to_char(s.id) = o.oneagentid) as oneagent,o.real_name as directagent "
				+ "from apstfr.tbl_tfr_mchnt_freeze_list t left join tbl_mcht_inf tb on t.mchnt_cd = tb.mcht_cd "
				+ "left join t_operators o on tb.ext1 = to_char(o.id) where 1=1 ");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		
		return "  order by t.rec_upd_ts desc ";
	}

	public String getMchntCd() {
		return mchntCd;
	}

	public void setMchntCd(String mchntCd) {
		this.mchntCd = mchntCd;
	}

	public String getUseStatus() {
		return useStatus;
	}

	public void setUseStatus(String useStatus) {
		this.useStatus = useStatus;
	}

	public String getFreezeFlag() {
		return freezeFlag;
	}

	public void setFreezeFlag(String freezeFlag) {
		this.freezeFlag = freezeFlag;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getOpr() {
		return opr;
	}

	public void setOpr(String opr) {
		this.opr = opr;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getOldKeys() {
		return oldKeys;
	}

	public void setOldKeys(String oldKeys) {
		this.oldKeys = oldKeys;
	}
	
}
